﻿using SD.ContentSystem.Domain.Entities;
using SD.ContentSystem.Domain.IRepositories.Interfaces;
using SD.Infrastructure.Repository.EntityFramework;
using System;
using System.Linq;
using System.Linq.Expressions;

namespace SD.ContentSystem.Repository.Implements
{
    /// <summary>
    /// 相册仓储实现
    /// </summary>
    public class PhotoAlbumRepository : EFAggRootRepositoryProvider<PhotoAlbum>, IPhotoAlbumRepository
    {
        #region # 根据条件获取实体对象集合（默认排序） —— override IOrderedQueryable<PhotoAlbum> FindBySort(...
        /// <summary>
        /// 根据条件获取实体对象集合（默认排序）
        /// </summary>
        /// <returns>实体对象集合</returns>
        protected override IOrderedQueryable<PhotoAlbum> FindBySort(Expression<Func<PhotoAlbum, bool>> condition)
        {
            return base.Find(condition).OrderBy(x => x.Sort).ThenByDescending(x => x.AddedTime);
        }
        #endregion
    }
}
